<template>
  <div class="inside-page">
    <div class="create">
      <h1>订单已生成</h1>
      <h3>
        您可在「我的」-「订单中心」查看该订单，或前往「我的」-「加入双选会」继续报名更多双选会。
      </h3>
      <div class="choice-list-item" v-for="v in isChooseList" :key="v.id">
        <div class="top-wrap clearfix">
          <div class="logo">
            <img :src="v.images" />
          </div>
          <div class="text-wrap">
            <p class="name-wrap">
              <span class="title" :title="v.name">{{ v.name }}</span>
              <span
                class="corner"
                :class="[v.type === 0 ? 'online' : 'offline']"
              >
                {{ v.type === 0 ? '线上专场' : '线下专场' }}
              </span>
            </p>
            <p class="pro">主办单位：{{ v.for_name }}</p>
            <div class="icon-wrap">
              <span class="time">
                <i class="iconfont icon-time"></i>
                <span>双选会时间：{{ v.start_time }} - {{ v.end_time }}</span>
              </span>
              <span class="address">
                <i class="iconfont icon-map"></i>
                <span v-if="v.type === 0">线上</span>
                <span v-else>{{ v.address }}</span>
              </span>
            </div>
          </div>
          <p class="money">¥{{ v.amount }}</p>
        </div>
        <div class="state">
          <p>报名截止: {{ v.push_end_time_cn }}</p>
        </div>
      </div>
    </div>
    <div class="submit">
      <button class="confirm" type="button" @click="jumpTo(1)">前往支付</button>
      <button class="cancel" type="button" @click="jumpTo(2)">
        报名更多场次
      </button>
    </div>
  </div>
</template>

<script>
import { orderInfo } from '@/api/order';

export default {
  asyncData: ({ req }) => ({
  }),
  components: {},
  data () {
    return {
      orderId: '',
      isChooseList: [],
    }
  },
  head () {
    return {
      titleTemplate: (titleChunk) => {
        return `${titleChunk} - 大学生找工作、找实习`;
      }
    }
  },
  created () {
    this.orderId = this.$route.query.id;
    this.fetchData();
  },
  mounted () {
  },
  watch: {

  },
  computed: {

  },
  methods: {
    jumpTo (index) {
      if (index === 1) {
        this.$router.push({
          path: '/order'
        })
      } else if (index === 2) {
        this.$router.push({
          path: '/choice/list'
        })
      }
    },
    async fetchData () {
      await orderInfo({
        order_id: this.orderId,
      }).then(res => {
        if (res.code) {
          this.isChooseList = [res.data];
        } else {
          this.$message.error(res.msg);
        }
      }).catch(err => {
        console.error(err)
        this.$message.error(err);
      })
    },
  },
}
</script>

<style lang="scss" scoped>
.inside-page {
  width: 100%;
  position: relative;
  .create {
    width: 100%;
    height: 400px;
    padding-top: 50px;
    background: #f6f7f8;
    position: relative;
    h1 {
      line-height: 60px;
      font-size: 38px;
      color: $base-color;
      text-align: center;
    }
    h3 {
      font-size: 14px;
      color: #666;
      text-align: center;
      margin: 10px 0 40px 0;
    }
    .choice-list-item {
      position: relative;
      min-height: 170px;
      width: 900px;
      padding: 0 30px;
      margin: 10px auto;
      border: 1px solid #ebebeb;
      background: #fff;
      box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
      .top-wrap {
        min-height: 120px;
      }
      .logo {
        float: left;
        margin-top: 23px;
        height: 74px;
        width: 74px;
        overflow: hidden;
        background: #fff;
        text-align: center;
        font-size: 0;
        border: 1px solid #ebebeb;
        img {
          height: 100%;
        }
      }
      .text-wrap {
        float: left;
        margin: 23px 0 0 20px;
        position: relative;
        .name-wrap {
          width: 580px;
          line-height: 24px;
          .title {
            font-size: 18px;
            color: #24292f;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2;
            overflow: hidden;
          }
          .corner {
            vertical-align: top;
            display: inline-block;
            margin-left: 5px;
            margin-top: 5px;
            width: 70px;
            height: 22px;
            line-height: 20px;
            font-size: 12px;
            text-align: center;
            border-radius: 4px;
            &.online {
              background: rgba(71, 113, 220, 0.3);
              color: $base-color;
              border: 1px solid $base-color;
            }
            &.offline {
              background: rgba(252, 112, 62, 0.3);
              color: $base-color-important;
              border: 1px solid $base-color-important;
            }
          }
        }
        .pro {
          margin: 10px 0;
          font-size: 12px;
          color: #ccc;
        }
        .icon-wrap {
          .time,
          .address {
            margin-top: 10px;
            height: 20px;
            line-height: 20px;
            margin-right: 20px;
            i,
            span {
              margin-right: 5px;
              font-size: 14px;
              color: #999;
            }
          }
        }
      }
      .money {
        position: absolute;
        right: 40px;
        top: 50px;
        font-size: 24px;
        color: $base-color-important;
      }
      .state {
        height: 50px;
        line-height: 50px;
        padding-left: 10px;
        margin-top: 10px;
        position: relative;
        border-top: 1px solid #ebebeb;
        &::before {
          content: '';
          height: 16px;
          width: 2px;
          background: $base-color;
          position: absolute;
          left: 0;
          top: 17px;
        }
        p {
          color: #999;
        }
      }
    }
  }
}
</style>
